package com.yang.mall.tools;


import org.springframework.util.StringUtils;

public class NumberUtil {
    private static NumberUtil util = new NumberUtil();
    private int id;

    private NumberUtil() {
        this.id = 1000;
    }

    public static String getId() {
        long id = 0;
        synchronized (NumberUtil.util) {
            if (util.id > 9999) util.id = 1000;
            id = ++util.id;

        }
        return String.valueOf(id).substring(1);
    }


    public static String getFormatMobile(String mobile) {
        if (!StringUtils.isEmpty(mobile)) {
            String str1 = mobile.substring(0, 3);
            String str2 = mobile.substring(7);
            return str1 + "****" + str2;
        }
        return "";
    }

    public static String getUserCode(Long size) {

        String code = size + "";
        if (size < 10000000) {
            String str = "00000000";
            int a = str.length() - size.toString().length();
            String b = str.substring(0, a) + size;
            code = b;
        }
        return code;
    }

    public static String getStoreCode(Long size) {

        String code = size + "";
        if (size < 100000) {
            String str = "000000";
            int a = str.length() - size.toString().length();
            String b = str.substring(0, a) + size;
            code = b;
        }
        return code;
    }

    public static String getRegionId(Integer size) {

        String code = size + "";
        if (size < 9999) {
            String str = "0000";
            int a = str.length() - size.toString().length();
            String b = str.substring(0, a) + size;
            code = b;
        }
        return code;
    }


}
